# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=py3-pam
_pkgname=python-pam
pkgver=2.0.2
pkgrel=2
pkgdesc="A Python interface to the PAM library"
url="https://github.com/FirefighterBlu3/python-pam"
arch="noarch"
license="MIT"
depends="linux-pam python3 py3-six"
makedepends="py3-setuptools py3-wheel py3-gpep517 py3-installer"
checkdepends="py3-pytest"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/FirefighterBlu3/python-pam/archive/v$pkgver.tar.gz"
builddir="$srcdir"/$_pkgname-$pkgver

replaces="py-pam" # Backwards compatibility
provides="py-pam=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	case "$CARCH" in
	aarch64)
		.testenv/bin/python3 -m pytest \
		--deselect tests/test_internals.py::test_PamAuthenticator__normal_success \
		--deselect tests/test_internals.py::test_PamAuthenticator__unset_DISPLAY \
		--deselect tests/test_internals.py::test_PamAuthenticator__env_set \
		--deselect tests/test_internals.py::test_PamAuthenticator__open_session_unauthenticated \
		--deselect tests/test_internals.py::test_PamAuthenticator__close_session_unauthenticated
		;;
# FAILED tests/test_internals.py::test_PamAuthenticator__normal_success - asser...
# FAILED tests/test_internals.py::test_PamAuthenticator__unset_DISPLAY - assert...
# FAILED tests/test_internals.py::test_PamAuthenticator__env_set - assert True ...
# FAILED tests/test_internals.py::test_PamAuthenticator__close_session_unauthenticated
	*)
		.testenv/bin/python3 -m pytest \
		--deselect tests/test_internals.py::test_PamAuthenticator__open_session_unauthenticated
		;;
#FAILED tests/test_internals.py::test_PamAuthenticator__open_session_unauthenticated - assert 14 == 10
	esac
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
eafeb753b22ffccc1c5729516ea1ae26799d3749140fe91849ddb804066cabd4b5493e9b059172977dd5b3c5d48c8b5ced6c5c944931fcf23225dda09db026f6  py3-pam-2.0.2.tar.gz
"
